/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-04-21 10:32:37
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-07-19 09:47:08
 * @FilePath: \cxl-h5\src\pages\personalCenter\message\detailed\index.ts
 */
import { noticeDetailedById } from '@/apis/notice'
import { editPageTitle } from '@/utils'
import { BasicData } from '@/utils/basicData'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'

export default class MessageDetailed extends BasicData {
    //标题
    title = ref('')
    //时间
    time = ref('')
    //内容
    content = ref('')
    //监听滚动元素
    scrollEl: any
    windowHeight = 0
    constructor() {
        super()
        const route = useRoute()
        console.log(route.params)
        const id = route.params.id as string
        if (id) {
            noticeDetailedById(id).then(res => {
                if (res.data.value === 200) {
                    this.title.value = res.data.data.title
                    this.time.value = res.data.data.releaseTime
                    this.content.value = res.data.data.content
                    editPageTitle(this.title.value)
                }
            })
        }

        this.windowHeight = window.innerHeight

        onMounted(() => {
            // this.scrollEl = document.querySelector('.message-detailed') as HTMLElement
            // this.scrollEl?.addEventListener('scroll', this.onScroll, false)
        })
        // onUnmounted(() => {
        //     this.scrollEl?.addEventListener('scroll', this.onScroll, false)
        // })
    }
    //监听滚动
    onScroll = () => {
        // console.log(this.scrollEl?.scrollTop)
    }
}
